<template>
	<view>
		<!-- 报警管理详情 -->
		<view class="page">
			<view class="example-body">
				<uni-nav-bar background-color="#003466" color="#ffffff" :status-bar="true" @click-left="back" left-icon="arrowleft" style="position: relative;">
					<view class="flex-item">报警详情</view>
				</uni-nav-bar>
			</view>
			<view class="alarm-container">
				<navigator class="alarm-option" url="../../message-center/message-center">
					<view class="alarm-optionleft">报警类型</view>
					<view class="alarm-optionright">{{ objData.type }}</view>
				</navigator>
				<view class="alarm-option">
					<view class="alarm-optionleft">所属系统</view>
					<view class="alarm-optionright">{{ objData.systemName? objData.systemName:'--'}}</view>
				</view>
				<view class="alarm-option">
					<view class="alarm-optionleft">报警对象</view>
					<view class="alarm-optionright">{{ objData.objectRowGuid }}</view>
				</view>
				<view class="alarm-option">
					<view class="alarm-optionleft">报警地点</view>
					<view class="alarm-optionright">{{ objData.location }}</view>
				</view>
				<view class="alarm-option">
					<view class="alarm-optionleft">报警级别</view>
					<view class="alarm-optionright">{{ objData.level }}</view>
				</view>
				<view class="alarm-option">
					<view class="alarm-optionleft">报警状态</view>
					<view class="alarm-optionright">{{ objData.status }}</view>
				</view>
				<view class="alarm-option newoption">
					<view class="alarm-optioninput">报警描述</view>
					<textarea :value="objData.description" placeholder="报警描述" class="alarm-input" />
				</view>
			<!-- 	<view class="alarm-option newoption"> 
				<view class="alarm-optionleft newalarm-optionleft">维护分队</view>
					<view style="width: 88%; float: right;height: 120px;">
						<xfl-select
							:list="teamData"
							:showItemNum="2"
							:initValue="item.i"
							:isCanInput="false"
							:style_Container="listBoxStyle"
							:placeholder="'请选择'"
							
							@visible-change="visibleChange"
						></xfl-select>
						 
					</view>
				</view> -->
			</view>
		<!-- 	<view class="alarm-write">填写故障处理记录</view> -->
		</view>
	</view>
</template>

<script>
import uniDrawer from '@/components/uni-drawer/uni-drawer.vue';
import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue';
import uniIcon from '@/components/uni-icon/uni-icon.vue';
import xflSelect from '@/components/xfl-select/xfl-select.vue';
import tools from '@/common/tools-new.js';
export default {
	data() {
		return {
			listBoxStyle: `height: 40px; font-size: 16px;`,
			//teamData: [],
			objData: [], //详情获取
			objInf: [],//报警地点
			targetData:[],//报警对象
			dic_data: [
				{
					name: '报警类型',
					data: []
				},
				{
					name: '优先级别',
					data: []
				}
			]
		};
	},
	components: {
		uniNavBar,
		uniIcon,
		xflSelect
	},
	methods: {
		getOptionList(id) {
			let param = { id: id };
			this.$api.AlarmManage.AlarmOption(param)
				.then(res => {
					// console.log(res)
					this.objData = res[1].data.result;
						this.objData.location = this.objInf.find(e => e.id == this.objData.location) == undefined ? '--' : this.objInf.find(e => e.id == this.objData.location).roomName;
						if (this.objData.objectRowGuid == '' || this.objData.objectRowGuid == null) {
							this.objData.objectRowGuid = this.objData.objectName;
						} else {
							this.objData.objectRowGuid =
								this.targetData.find(e => e.ojbectId == this.objData.objectRowGuid) == undefined ? '--' : this.targetData.find(e => e.ojbectId == this.objData.objectRowGuid).ojbectName;
						}
					
					
					//取所属系统名称
					if (this.objData != null) {
						this.objData.systemName=this.$helper.getTextByValue('所属系统', this.objData.systemName);
						this.objData.type = this.$helper.getTextByValue('报警类型', this.objData.type);
						this.objData.level = this.$helper.getTextByValue('优先级别', this.objData.level);
						this.objData.status = this.$helper.getTextByValue('报警状态', this.objData.status);
					}
				})
				.catch(res => {
					//接口请求失败
					uni.showToast({
						title: '接口请求数据失败',
						duration: 2000
					});
				});
		},

		//初始化房间数据
		getRommList() {
			this.$api.AlarmManage.AlarmLocation()
				.then(res => {
					this.objInf = res[1].data.result;
					// console.log(this.objInf)
				})
				.catch(res => {
					uni.showToast({
						title: '报警地点获取失败',
						duration: 2000
					});
				});
		},

		getTargetList() {
			this.$api.AlarmManage.AlarmTarget()
				.then(res => {
					this.targetData = res[1].data.result;
				})
				.catch(res => {
					uni.showToast({
						title: '报警对象获取失败',
						duration: 2000
					});
				});
		},
 //       getTeam(){
	// //维护队伍
	//  this.$api.MaintenanceTask.ShowTeamData()
	// 	.then(res => {
	// 		this.teamData = res[1].data.result;
	// 		
	// 		this.teamData.forEach(ele => {
	// 			this.teamData.push(ele.teamName);
	// 		})
	// 	})
	// 	.catch(res => {
	// 		uni.showToast({
	// 			title: '维护队伍获取失败',
	// 			duration: 2000
	// 		});
	// 	});
	// 
 //           },
		back() {
			uni.navigateBack({
				delta: 1
			});
		}
	},

	//初次加载数据
	onLoad: async function(option) {
		await this.getTargetList();
		await this.getRommList();
		//await this.getTeam();
      this.getOptionList(option.id);
	}
};
</script>

<style>
page {
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	background-color: #F2F2F2;
}

.example-body{
	z-index: 15;
}

.flex-item {
	font-size: 20px;
	text-align: center;
}

.uni-icon {
	padding-left: 42%;
}

.uni-navbar__header-btns:last-child {
	width: 120px;
}

.uni-navbar__header-btns {
	padding: 0;
}
/* 头部样式 */
.alarm-container {
	width: 94%;
	margin: 0 auto;
	margin-top: 10px;
	background-color: #ffffff;
	border-radius: 3px;
	overflow: hidden;
}

.alarm-option {
	width: 96%;
	border-bottom: 1px solid #eeeeee;
	overflow: hidden;
	font-size: 16px;
	margin: 0 auto;
	padding: 14px 0px;
}

.alarm-optionleft {
	float: left;
	color: #333333;
}

.alarm-optionright {
	float: right;
	color: #666666;
}

.alarm-input {
	width: 96.9%;
	font-size: 14px;
	float: inherit;
	border: 1px solid #e5e5e5;
	margin-top: 10px;
	padding-top: 10px;
}

.alarm-optioninput {
	color: #333333;
}

textarea {
	height: 100px;
	color: #666666;
}

.newoption {
	border: none;
	overflow: hidden;
}

input {
	outline: none;
}

.alarm-write {
	width: 94%;
	height: 52px;
	line-height: 52px;
	margin: 0 auto;
	border-radius: 3px;
	font-size: 16px;
	color: #ffffff;
	text-align: center;
	background-color: #169bd5;
	margin-top: 15px;
}

.newalarm-optionleft {
	margin-top: 10px;
}
</style>
